package com.dmzc.stage1.chapter3;

import java.util.concurrent.TimeUnit;

/**
 * 测试ThreadInterrupted方法
 */
public class ThreadInterrupt1 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread=new Thread(()->{
            while (true){
                if (Thread.interrupted()){
                    System.out.println("true");
                    break;
                }

            }

        });
        thread.start();
        TimeUnit.MILLISECONDS.sleep(2);
        thread.interrupt();
    }
}
